package com.wx.ribbon.order.controller;

import com.wx.commons.entiy.PaymentDo;
import com.wx.commons.result.R;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @author: 王霄
 * @date: 2021/12/24 21:42
 */
@RestController
@RequestMapping("/order1")
public class OrderController {

    // public static final String PAYMENT_URL = "http://localhost:8001/payment";
    public static final String PAYMENT_URL = "http://paymentServer/payment/";

    @Resource
    private RestTemplate restTemplate;

    @PostMapping("/create")
    public R<?> create(@RequestBody PaymentDo paymentDo) {
        return restTemplate.postForObject(PAYMENT_URL + "create", paymentDo, R.class);
    }

    @GetMapping("/queryById/{id}")
    public R<?> getPayment(@PathVariable("id") Long id) {
        return restTemplate.getForObject(PAYMENT_URL + "queryById/" + id, R.class);
    }
}
